<template>
  <div class="list-table">
    <!-- <div class="area-header">
      <span class="area-header-title">{{ $t('出资人收益测算') }}</span>
    </div> -->
    <el-form ref="queryForm" :model="queryParams" :inline="true" :rules="queryRules">
      <el-form-item :label="$t('出资人名称')" prop="investorId">
        <el-select v-model="queryParams.investorId" filterable clearable @change="dataChange()">
          <el-option
            v-for="item in investorOptions"
            :key="item.id"
            :label="item.userName"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('截止时间')" prop="endDate">
        <DatePicker v-model="queryParams.endDate" :placeholder="$t('截止时间')" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="queryHandle">{{ $t("搜索") }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t("重置") }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="fundLpReportList" border>
      <el-table-column :label="$t('业务日期')" align="center" prop="businessDate" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.businessDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('实缴金额') + $t('金额单位')" align="center" prop="paidInScale" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.paidInScale, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('分配本金') + $t('金额单位')" align="center" prop="principalBack" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.principalBack, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('本金余额') + $t('金额单位')" align="center" prop="principalBalance" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.principalBalance, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('当日 Hurdle') + $t('金额单位')" align="center" prop="incomeThisDate" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.incomeThisDate, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('累计 Hurdle') + $t('金额单位')" align="center" prop="incomeSum" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.incomeSum, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('支付 Hurdle') + $t('金额单位')" align="center" prop="incomeBack" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.incomeBack, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('累计已支付 Hurdle') + $t('金额单位')" align="center" prop="incomeBackSum" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.incomeBackSum, 'w') }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('未支付 Hurdle') + $t('金额单位')" align="center" prop="incomeBalance" show-overflow-tooltip min-width="120">
        <template slot-scope="scope">
          <span class="money-text">{{ moneyFormat(scope.row.incomeBalance, 'w') }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { listIncomeMeasure, listFundInvestorAll } from '@/api/fund/investor/fundInvestor'
export default {
  data() {
    return {
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      // 出资人缴款表格数据
      fundLpReportList: [],
      // 查询参数
      queryParams: {
          investorId: undefined,
          endDate: undefined,
          fundId: this.$route.query.id
      },
      queryRules: {},
      // 表单参数
      form: {},
      // 出资人下拉
      investorOptions: []
    }
  },
  created() {
      this.getAllInvestor()
      this.getList()
  },
  methods: {
    /** 查询出资人缴款列表 */
    getList() {
      if (this.queryParams.investorId) {
        this.loading = true
        listIncomeMeasure(this.queryParams).then(response => {
          this.fundLpReportList = response.rows
          this.total = response.total
          this.loading = false
        })
      }
    },
    getAllInvestor() {
      // 获取所有出资人
      listFundInvestorAll(this.queryParams).then(res => {
        this.investorOptions = res.data
      })
    },
    dataChange() {
      this.getList()
    },
    /** 搜索按钮操作 */
    queryHandle() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.queryHandle()
    }
  }
}
</script>
